package com.liuyang.demo.time;

import java.text.SimpleDateFormat;
import java.time.ZoneId;
import java.time.temporal.TemporalAccessor;
import java.util.Date;
import java.util.TimeZone;

public class DateTimeDemo {
    public static void main(String[] args) {
        String s = DateUtil.formatDate(new Date());
        System.out.println(s);
        String s1 = DateUtil.formatDateTime(new Date());
        System.out.println(s1);

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
        System.out.println(simpleDateFormat.getTimeZone());
        System.out.println(simpleDateFormat.format(new Date()));

        TimeZone tz = TimeZone.getDefault();
        //北京时区
        tz = TimeZone.getTimeZone("GMT+2");
        simpleDateFormat.setTimeZone(tz);
        System.out.println(simpleDateFormat.format(new Date()));


        String dateString = "2021-07-01T10:21:55Z";
    }

}
